const { app: electronApp } = require('electron');
const amqp = require('amqplib');
const is = require('ee-core/utils/is');
const Log = require('ee-core/log');
const Conf = require('ee-core/config');
const CoreWindow = require('ee-core/electron/window');

const serverConfig = {
  protocol: 'amqp',
  hostname: '127.0.0.1',
  port: 5672,
  username: 'common_cast',
  password: 'Rmq123456',
  vhost: '/'
};


/**
 * Rabbitmq
 * @class
 */
class AmqplibAddon {

  constructor() {
  }

  /**
   * 创建
   */
  create () {
    Log.info('[addon:amqplib] load');
    const cfg = Conf.getValue('addons.amqplib');
    if ((is.windows() && cfg.windows)
        || (is.macOS() && cfg.macOS)
        || (is.linux() && cfg.linux))
    {
      // continue
    } else {
      return
    }


  }


  /**
   * 向前端发消息
   */
  sendStatusToWindow(content = {}) {
    const textJson = JSON.stringify(content);
    const channel = 'app.updater';
    const win = CoreWindow.getMainWindow();
    win.webContents.send(channel, textJson);
  }
  
}

AmqplibAddon.toString = () => '[class AmqplibAddon]';
module.exports = AmqplibAddon;